import cv2
import numpy as np
from pyzbar.pyzbar import decode
cap=cv2.VideoCapture(0)
while True:
    ret,frame=cap.read()
    for barcode in decode(frame):
        mydate=barcode.date.decode('utf-8')
        pts=np.array([barcode.polygon],np.uint32)
        pts=pts.reshape((-1,1,2))
        cv2.polylines(frame,[pts],True,(255,0,0),5)
        pts2=barcode.rect
        cv2.putText(frame,mydate,(255,0,0),(pts2[0],pts2[1]),cv2.FONT_HERSHEY_COMPLEX,0.9,(255,0,0),2)
    cv2.waitKey(1)
